<template>
    <el-menu class="sidebar-style" :default-active="activeItem" @select="handleSelect" :unique-opened='true'>
      <el-menu-item-group v-for="(value, index) in routes" :key="index">

        <el-submenu v-if="value.children && value.children[0].isLeafnode == 1" :index="value.title">
          <template slot="title">{{value.title}}</template>
          <el-menu-item v-for="(item, index) in value.children" :key="index" @click="click(item.menuUrl, item.title)" :index='item.title'>{{item.title}}</el-menu-item>
        </el-submenu>

        <el-menu-item v-else-if="value.children[0].isLeafnode == 0" @click="click(value.menuUrl, value.title)" :index="value.title">{{value.title}}</el-menu-item>
      </el-menu-item-group>
    </el-menu>
</template>
<script>
import util from '@/util'
export default {
    props: ['routes', 'activeItem', 'asideActive'],
    methods:{
      handleSelect(key, keyPath) {
        this.$store.commit("SET_ASIDEISCLICK", true);
        this.$store.commit("SET_ASIDEACTIVE", key);
      },
      click (path, title) {
        if (title != this.asideActive) {
            util.routerTo(path)
        }
      }
    }
}
</script>
<style lang="less">
.sidebar-style{
    .el-submenu__title.is-active {
      background: rgba(219, 240, 253, 1);
      color: #2da3ea;
    }
    .el-menu-item.is-active {
      background: rgba(219, 240, 253, 1);
      color: #2da3ea;
    }
}
</style>
